unable to "Delete All" when purging soft deleted mailboxes
I run the following commands to delete all disconnected mailboxes on my system, for example when I am doing a mailbox move, or to recover space. 1. I create an array $Mailboxes with all "Soft Deleted" mailboxes $Mailboxes = Get-MailboxStatistics -Database "MBX1" | where {$_.DisconnectReason -eq SoftDeleted} 2. Then a Foreach loop to remove all soft deleted mailboxes $Mailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted} However I then get the following prompt. When I press "A" to delete ALL of them, it only deletes one of them, so I have to press "Y" about 100 times, once for each mailbox. Confirm Are you sure you want to perform this action? Removing mailbox "bcabc60d-2004-4b05-80a0-02f84078e007" on database "MBX1". [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): A Confirm Are you sure you want to perform this action? Removing mailbox "96306e63-ebce-4d6c-9df8-08d45f1175a1" on database "MBX1". [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is "Y"): What am I doing wrong?
July 3rd, 2012 8:16am

Hi You can use this command to prevent the confirmation prompt: $Mailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted -Confirm:$False} Steve ETA: The reason why you get prompted after pressing A the first time is the foreach loop runs each object in the array as a new command.
Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2012 8:28am

The reason why you get prompted after pressing A the first time is the foreach loop runs each object in the array as a new command. Of course - this makes perfect sense. Thankyou SO much for that! Something so simple, just tried it and it works brilliantly. Still on the powershell learning curve so new tips and shortcuts like this are brilliant help thanks
July 3rd, 2012 9:03am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics